1 <?
2 $path =
"../images/cat";
3 $pathdb =
"images/cat";
4 if
(isset($_POST['butSaveLoai'])) {
5     $parent = $_POST[
'txtParent'];
6     $order = $_POST[
'txtSortOrder'];
7     
if($order=='') $order=0;
8     
else $order = $_POST['txtSortOrder'];
9
10     $status=($_POST[
'chkShow']!=''?1:0);
11             
12     $CategoryName= trim($_POST[
'txtName']);
13     $err.=CheckUpload($_FILES[
"txtImage"],".jpg;.gif;.bmp;.png;.swf",500*1024,$_POST['id']==''?1:0);
14     
if ($CategoryName=="")
15     {
16         echo
"<p align=center class='err'>B&#7841;n ch&#432;a nh&#7853;p tên danh m&#7909;c</p>";
17     }
18     
else
19     {
20         $catinfo=GetCatInfo($parent);
21         $language=$catinfo[
'language'];
22         
if (!empty($_POST['oldid'])) {
23             $oldid = $_POST[
'oldid'];
24             $sql =
"update cat set name='".$CategoryName."', parent='".$parent."', thutu='".$order."', status=".$status." where id='".$oldid."'";
25         }
26         
else
27             $sql =
"insert into cat (name, parent, thutu, status) values ('".$CategoryName."','".$parent."','".$order."','".$status."')";
28         
if (mysql_query($sql,$con)) {
29             
if(empty($_POST['id'])) $oldid = mysql_insert_id();
30             $sqlUpdateField =
"";
31             $extsmall=GetFileExtention($_FILES[
'txtImage']['name']);
32             
if (MakeUpload($_FILES['txtImage'],"$path/cat_home_s$oldid$extsmall"))
33             {
34                 @chmod(
"$path/cat_home_s$oldid$extsmall", 0777);
35                 $sqlUpdateField =
" image='$pathdb/cat_home_s$oldid$extsmall' ";
36             }
37             
if($sqlUpdateField)
38             {
39                 $sqlUpdate =
"update cat set $sqlUpdateField where id='".$oldid."'";
40                 mysql_query($sqlUpdate,$con);
41             }
42             echo
"<p align=center class='err'>&#272;ã c&#7853;p nh&#7853;t thành công</p><br>";
43             echo
"<script>window.location='index.php?act=category&cat=".$_REQUEST['cat']."&page=".$_REQUEST['page']."'</script>";
44         }
45         
else echo "<p align=center class='err'>Không th&#7875; c&#7853;p nh&#7853;t</p>";
46     }
47 }
48 ?>
49 <?
50 $path =
"../images/cat";
51 $pathdb =
"images/cat";
52 if
(isset($_POST['butSaveLoai'])) {
53     $parent = $_POST[
'txtParent'];
54     $order = $_POST[
'txtSortOrder'];
55     
if($order=='') $order=0;
56     
else $order = $_POST['txtSortOrder'];
57     $status=($_POST[
'chkShow']!=''?1:0);
58     $CategoryName= trim($_POST[
'txtName']);
59
60     $err=
"";
61     
if ($CategoryName=="") $err .= "Xin nh&#7853;p tên<br>";
62     $err.=CheckUpload($_FILES[
"txtImage"],".jpg;.gif;.bmp;.png;.swf",500*1024,$_POST['id']==''?1:0);
63     
64     
if ($err=='')
65     {
66         
if (!empty($_POST['id'])) {
67             $oldid = $_POST[
'id'];
68             $sql =
"update cat set name='".$CategoryName."', parent='".$parent."', thutu='".$order."', status=".$status." where id='".$oldid."'";
69         }
else {
70             $sql =
"insert into cat (name, parent, thutu, status) values ('".$CategoryName."','".$parent."','".$order."','".$status."')";
71         }
72         
if (mysql_query($sql,$con)) {
73             
if(empty($_POST['id'])) $oldid = mysql_insert_id();
74
75             $sqlUpdateField =
"";
76             
77             $extsmall=GetFileExtention($_FILES[
'txtImage']['name']);
78             
if (MakeUpload($_FILES['txtImage'],"$path/slider_home_s$oldid$extsmall"))
79             {
80                 @chmod(
"$path/slider_home_s$oldid$extsmall", 0777);
81                 $sqlUpdateField =
" image='$pathdb/slider_home_s$oldid$extsmall' ";
82             }
83             
if($sqlUpdateField)
84             {
85                 $sqlUpdate =
"update cat set $sqlUpdateField where id='".$oldid."'";
86                 mysql_query($sqlUpdate,$con);
87             }
88         }
89         
else {
90             $err =
"<p align=center class='err'>Không th&#7875; c&#7853;p nh&#7853;t</p>";
91         }
92     }
93     
if ($err=='') echo "<script>window.location='index.php?act=category&cat=".$_REQUEST['cat']."&page=".$_REQUEST['page']."'</script>";
94     
else echo '<p align=center class="err" style="line-height: 150%">'.$err.'</p>';
95 }
96 ?>
97 <?
98     
if (isset($_GET['id'])) {
99         $oldid=$_GET[
'id'];
100         $sql =
"select * from cat where id='".$oldid."'";
101         
if ($result = mysql_query($sql,$con)) {
102             $row=mysql_fetch_array($result);
103             $CategoryName=$row[
'name'];
104             $image=$row[
'image'];
105             $parent=$row[
'parent'];
106             $order=$row[
'thutu'];
107             $status=$row[
'status'];
108             $date=$row[
'date'];
109         }
110     }
111 ?>
112
113 <form method=
"POST" name="FormLoaiSP" enctype="multipart/form-data" action="index.php">
114 <input type=hidden name=
"act" value="category_m">
115 <input type=hidden name=
"oldid" value="<? echo $oldid; ?>">
116 <input type=hidden name=
"page" value="<? echo $_REQUEST['page']; ?>">
117 <input type=hidden name=
"cat" value="<? echo $_REQUEST['cat']; ?>">
118 <table border=
"1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
119   <tr>
120     <td width=
"45%" align="center" class="title" height="20">Thêm m&#7899;i / C&#7853;p nh&#7853;t : Danh m&#7909;c s&#7843;n ph&#7849;m</td>
121   </tr>
122   <tr>
123     <td width=
"45%">
124     <table border=
"0" cellpadding="4" bordercolor="#111111" width="124%" id="AutoNumber2" cellspacing="0">
125       <tr>
126         <td width=
"15%" class="smallfont">
127         <p align=
"right">Tên danh m&#7909;c</td>
128         <td width=
"1%" class="smallfont">
129         <font color=
"#FF0000">*</font></td>
130         <td width=
"83%" class="smallfont">
131         <INPUT
value="<? echo $CategoryName; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
132       </tr>
133       <tr>
134         <td width=
"15%" class="smallfont">
135         <p align=
"right">Hình Icon</td>
136         <td width=
"1%" class="smallfont" align="center">
137         &nbsp;</td>
138         <td width=
"83%" class="smallfont">
139         <INPUT TYPE=
"file" NAME="txtImage" CLASS=textbox size="34"></td>
140       </tr>
141       <tr>
142         <td width=
"15%" class="smallfont">
143         <p align=
"right">Thu&#7897;c danh m&#7909;c</td>
144         <td width=
"1%" class="smallfont">
145         &nbsp;</td>
146         <td width=
"83%" class="smallfont">
147         <
select size="1" name="txtParent">
148 <?
149         echo
"<option value='17'>[Danh m&#7909;c g&#7889;c]</option>";
150         $cats=GetListCat(
17);
151         
foreach ($cats as $cat)
152         {
153             
if ($cat[0]==$parent)
154                 echo
"<option value=".$cat[0]." selected>".$cat[1]."</option>";
155             
else
156                 echo
"<option value=".$cat[0].">".$cat[1]."</option>";
157         }
158 ?>
159         </
select>
160         
161 </td>
162       </tr>
163       <tr>
164         <td width=
"15%" class="smallfont" align="right">
165         Không hi&#
7875;n th&#7883;</td>
166         <td width=
"1%" class="smallfont" align="right">
167         &nbsp;</td>
168         <td width=
"83%" class="smallfont">
169         <input type=
"checkbox" name="chkShow" value="ON" <? if ($status>0) echo 'checked' ?>></td>
170       </tr>
171     
172       <tr>
173         <td width=
"15%" class="smallfont" align="right">
174         Th&#
7913; t&#7921; s&#7855;p x&#7871;p</td>
175         <td width=
"1%" class="smallfont" align="right">
176         &nbsp;</td>
177         <td width=
"83%" class="smallfont">
178         <INPUT
value="<? echo $order; ?>" TYPE="text" NAME="txtSortOrder" CLASS=textbox size="34"></td>
179       </tr>
180       <tr>
181         <td width=
"15%" class="smallfont">
182         <p align=
"right">
183         <INPUT TYPE=
"submit" NAME="butSaveLoai" VALUE="C&#7853;p nh&#7853;t" CLASS=button>&nbsp;</td>
184         <td width=
"1%" class="smallfont">
185         &nbsp;</td>
186         <td width=
"83%" class="smallfont"><p align="left">&nbsp;<INPUT TYPE="reset" CLASS=button value="Nh&#7853;p l&#7841;i"></td>
187       </tr>
188     </table>
189     </td>
190   </tr>
191   </table>
192 </form>



Full source code website bán hàng thương mại điện tử gần giống shopee 468.937 lượt xem

Gõ tìm kiếm nhanh...